%% Generate OVerview and safa as PDF

% should contain following plots and informations:
%
% 1) Filename
% 2) RAW data
% 3) Ramanshifted Data
% 4) ALS corrected Data
% 5) Footer conversion parameters

%% ===== Draw Figure =====
scrsz = get(0,'ScreenSize');
    fhight = (scrsz(4)-150);
    fwidth = (fhight*0.707);
    fleft  = (scrsz(3)-fwidth)/2;

A4=figure(453);
    set(A4, 'Position',[fleft 50 fwidth fhight], ...
        'Name', 'APE Data Overview', ...
        'PaperType', 'A4',...
        'Color',[1 1 1], ...
       'PaperUnits', 'normalized', ...
       'PaperOrientation','portrait', ...
       'PaperPosition', [0, 0, 1, 1])
%                'PaperOrientation','portrait')
   
% ----- print header -----
    annotation('textbox',[0.1 0.95 0.8 0.05],...
        'Interpreter','none', 'LineStyle', 'none', ...
        'string',{footer.FileName; ['Generated on ',date]})

%% ===== PLOT DATA =====  
subplot(4,3,[1:3])
    plot(datax,datay)
        title('Raw data')
        xlabel('Wavelength (nm)')
        ylabel('counts (AU)')

subplot(4,3,[4:6])
    if exist('ramandatax','var')==1        
        plot(ramandatax,datay)
            title('Raman shifted')
            xlabel('Raman shift (cm^-^1)')
            ylabel('counts (AU)')
    end
        
subplot(4,3,[7:9])
    if exist('ALSdatay','var')==1        
        plot(ramandatax,ALSdatay)
            title('ALS baseline corrected')
            xlabel('Raman shift (cm^-^1)')
            ylabel('Intensity (AU)')
    end    

bottomtable = uitable('Parent', A4,...
    'Units','normalized','Position',[0.1 0.05 0.4 0.2], ...
    'FontSize',7,...
    'ColumnName',[{}], ...
    'RowName', fieldnames(footer), ...
    'Data', struct2cell(footer));

% footerout(1,:) = fieldnames(footer);
% footerout(2,:) = struct2cell(footer);
% footerstring = 
% footerout = char(footerout)
% % for i=1:length(footerout)
% %     textout = [char(footerout(1,i)),' : ',char(footerout(2,i))]
% % end
% 
% bottombox = uicontrol('style','text');
%     set(bottombox,'String',footerout,...
%     'Units','normalized','Position',[0.5 0.05 0.4 0.2])
    
%% ===== SAVE PDF =====    
print('-dpdf','output')

